package com.supermarket.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.*;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Component
@ConfigurationProperties(prefix = "user")
@TableName(value = "smbms_user")
public class User {
    @TableId(value = "id",type = IdType.AUTO)
    @Getter
    private Long id;
    
    @TableField("userCode")
    private String userCode;
    
    @TableField("userName")
    private String userName;
    
    @TableField("userPassword")
    private String userPassword;
    
    @TableField("salt")
    private String salt;
    
    @TableField("status")
    private Integer status;
    
    @TableField("gender")
    private Integer gender;
    
    @TableField("birthday")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date birthday;
    
    @TableField("phone")
    private String phone;
    
    @TableField("address")
    private String address;
    
    @TableField("headUrl")
    private String headUrl;
    
    @TableField("userRole")
    private Long userRole;
    
    @TableField("createdBy")
    private Long createdBy;
    
    @TableField("creationDate")
    private Date creationDate;
    
    @TableField("modifyBy")
    private Long modifyBy;
    
    @TableField("modifyDate")
    private Date modifyDate;

    @Setter
    @Getter
    @TableField(exist = false)
    private Role role;

    @TableField(exist = false)
    private String roleName;

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", userCode='" + userCode + '\'' +
                ", userName='" + userName + '\'' +
                ", userPassword='" + userPassword + '\'' +
                ", salt='" + salt + '\'' +
                ", status=" + status +
                ", gender=" + gender +
                ", birthday=" + birthday +
                ", phone='" + phone + '\'' +
                ", address='" + address + '\'' +
                ", headUrl='" + headUrl + '\'' +
                ", userRole=" + userRole +
                ", createdBy=" + createdBy +
                ", creationDate=" + creationDate +
                ", modifyBy=" + modifyBy +
                ", modifyDate=" + modifyDate +
                '}';
    }

}